﻿
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace BlowerSimulatorShell
{
    /// <summary>
    /// This class manages the simulated power state of the processor
    /// </summary>
    public class PowerManager
    {
        private bool m_powerState;

        /// <summary>
        /// Power Manager Cstor
        /// </summary>
        public PowerManager()
        {
            // initial state if OFF
            m_powerState = false;
        }

        /// <summary>
        /// Get Current Power State
        /// </summary>
        public bool PowerState
        {
            get { return m_powerState; }
        }

        /// <summary>
        /// Toggle Processor Power
        /// </summary>
        /// <returns></returns>
        public bool TogglePower()
        {
            if (m_powerState)
            {
                // Turn off
                Interop.KillProcessor();
            }
            else
            {
                // turn on
                Interop.StartProcessor();
            }

            m_powerState = !m_powerState;

            // return state
            return m_powerState;
        }
    }
}